<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    
    //构造
    function People(name,weight,height,func) {
        this.name = name;
        this.weight = weight;
        this.height = height;
        this.fun = func
        this.SayHello = function () {
            console.log(name+"say hello");
        }
    }
    function func()
    {
        console.log("haha");
    }
    let p1 = new People("小民",173,65,func);
    let p2 = new People("小刚",178,75,func);
    p1.fun();

      
    // var student = new Object();
    // student.name = '张三';
    // student.height = 174;
    // student['weight'] = 60
    // student.sayHello = function() {
        // console.log("hello "+ student.name);
        //此时需要student.name 因为不在类内定义
    // }
    // student.sayHello();


    //   var a = {};//创建空对象
    //   var student = {
    //     name  : '张三',
    //     height: 172,
    //     weight: 53,
    //     sayHello: function() {
    //         console.log("Hello,I am"+name);
    //     }
    //   }
      //1.使用.成员访问运算符来访问属性
    //   console.log(student.name);
      //2.使用【】访问属性，此时属性需要加上引号
    //   console.log(student['height']);
      //3.访问成员方法，不要忘记带上()
    //   student.sayHello();
    </script>
</body>
</html>